/*
 * @Author: duanguang
 * @Date: 2019-09-04 17:45:35
 * @LastEditTime: 2021-10-28 22:54:29
 * @LastEditors: duanguang
 * @Description: 
 * @FilePath: /legions-server/app/controller/table.ts
 * 「扫去窗上的尘埃，才可以看到窗外的美景。」
 */
import CommonController from '../abstract/controller/common';
import { ICustomTableItem } from '../../typings/custom/tableCustom.d';

/**
* @controller table 表格组件列数据处理
*/
export default class TableListCustomController extends CommonController {
  /**
  * @summary 编辑/添加自定义列信息
  * @description  添加或者编辑列自定义数据
  * @router post /table/edit
  * @request body editColumnsBody
  * @response 200 editColumnsResp 返回结果
  */
  public async edit() {
    // console.log(this.ctx.request.body);
    const body: {
      modulesUid: string;
      customColumns: ICustomTableItem[];
    } = this.ctx.request.body;
    const createResult = await this.ctx.service.tableListCustom.edit(body);
    this.success(createResult);
  }
  public async query() {
    const { ctx } = this;
    // @ts-ignore
    const query: { modulesUid: string } = ctx.query;
    const createResult = await this.ctx.service.tableListCustom.getQueryTableCustomItem(query.modulesUid);
    this.success(createResult);
  }
}
